<?php

class changePasswordForm extends sfForm
{
    public function configure()
    {
        $this->setWidgets(array(
            'oldpassword' => new sfWidgetFormInput(array('type' => 'password')),
            'newpassword' => new sfWidgetFormInput(array('type' => 'password')),
            'repeatnewpassword' => new sfWidgetFormInput(array('type' => 'password')),
        ));

        $this->widgetSchema->setLabels(array(
            'oldpassword'        => "Old Password",
            'newpassword'        => "New Password",
            'repeatnewpassword'    => "Re-type new password",
        ));

        $this->setValidators(array(
            'oldpassword' => new OldPasswordValidator(array(), array('invalid' => 'Password is wrong')),
            'newpassword' => new sfValidatorString(),
            'repeatnewpassword' => new sfValidatorString(),
        ));

        $this->validatorSchema->setPostValidator(new sfValidatorSchemaCompare('newpassword', sfValidatorSchemaCompare::EQUAL, 'repeatnewpassword', array(), array('invalid' => 'The two passwords are not matching')));

        $this->widgetSchema->setNameFormat('changepassword[%s]');
    }

}


